---
title: "RACIAL BIAS AND PUBLIC SUPPORT FOR US DRONE STRIKES = First Survey Experiment Replicaiton Kit"
author: "Paul Lushenko"
date: "6/26/2024"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE)
library(plyr)
library(dplyr)
library(ggplot2)
library(readr)
library(ggpubr)
library(tidyverse)
library(tidyr)
library(stargazer)
library(corrplot)
library(Hmisc)
library(margins)
library(magrittr)
library(wordcloud)
library(tm)
library(grid)
library(coefplot)
library(gplots)
library(car)
library(rstatix)
library(emmeans)
library(lmtest)
library(sandwich)
library(effects)
library(Interact)
library(sciplot)
library(lsr)
library(qwraps2)
library(gtsummary)
library(kableExtra)
library(caret)
library(ggthemes)
library(ggprism)
library(patchwork)
library(magrittr)
library(rstatix)
library(sjmisc)
library(scales)  
library(modelsummary)
```

```{r read in data, include=FALSE}
race <- read.csv("",
          stringsAsFactors = FALSE,                                                           
          na.string = ".") %>% filter(Finished == 1 & participate == 2) #for main analysis
questions <- read.csv("",
          stringsAsFactors = FALSE,                                                           
          na.string = ".") #for open_ended questions analysis
```

```{r format data, include=FALSE} 
race <- race[-(1:2),]
names <- as.data.frame(names(race))
race <- race %>% 
  select(-`StartDate`,
         -`EndDate`,
         -`Status`,
         -`IPAddress`,
         -`Progress`,
         -`Finished`,
         -`RecordedDate`,
         -`ResponseId`,
         -`RecipientLastName`,
         -`RecipientFirstName`,
         -`RecipientEmail`,
         -`ExternalReference`,
         -`LocationLatitude`,
         -`LocationLongitude`,
         -`DistributionChannel`,
         -`UserLanguage`,
         -`Q_RecaptchaScore`,
         -`participate`,
         -`Q7A_First.Click`,
         -`Q7A_Last.Click`,
         -`Q7A_Click.Count`,
         -`Q8A_First.Click`,
         -`Q8A_Last.Click`,
         -`Q8A_Click.Count`,
         -`Q9A_First.Click`,
         -`Q9A_Last.Click`,
         -`Q9A_Click.Count`,
         -`rid`,
         -`age`,
         -`gender`,
         -`hhi`,
         -`ethnicity`,
         -`hispanic`,
         -`education`,
         -`political_party`,
         -`region`,
         -`zip`,
         -`Q131`,
         -`Q132`,
         -`Q133`,
         -`Q134`,
         -`Respondent.Group2`)
race <- race %>% 
  mutate(group = `Respondent.Group`,
         control = case_when(group == 'Control Scenario' ~ 1,  
                             group != 'Control Scenario' ~ 0),
         t1_wa = case_when(group == 'Scenario #1, Treatment' ~ 1,
                        group != 'Scenario #1, Treatment' ~ 0),
         t2_we = case_when(group == 'Scenario #2, Treatment' ~ 1,
                        group != 'Scenario #2, Treatment' ~ 0),
         t3_wl = case_when(group == 'Scenario #3, Treatment' ~ 1,
                        group != 'Scenario #3, Treatment' ~ 0),
         t4_bra = case_when(group == 'Scenario #4, Treatment' ~ 1,
                        group != 'Scenario #4, Treatment' ~ 0),
         t5_bre = case_when(group == 'Scenario #5, Treatment' ~ 1,
                        group != 'Scenario #5, Treatment' ~ 0),
         t6_brl = case_when(group == 'Scenario #6, Treatment' ~ 1,
                        group != 'Scenario #6, Treatment' ~ 0),
         t7_bla = case_when(group == 'Scenario #7, Treatment' ~ 1,
                        group != 'Scenario #7, Treatment' ~ 0),
         t8_ble = case_when(group == 'Scenario #8, Treatment' ~ 1,
                        group != 'Scenario #8, Treatment' ~ 0),
         t9_bll = case_when(group == 'Scenario #9, Treatment' ~ 1,
                        group != 'Scenario #9, Treatment' ~ 0))
race <- race %>% 
  select(-`Respondent.Group`) 
race <- race %>% 
  mutate(skin = ifelse(control == 1, "Control",
                       ifelse(t1_wa == 1 | t2_we == 1 | t3_wl == 1, 'White', 
                       ifelse(t4_bra == 1 | t5_bre == 1 | t6_brl == 1, 'Brown', 'Black'))))
race <- race %>% 
  mutate(geography = ifelse(control == 1, "Control",
                            ifelse(t1_wa == 1 | t4_bra == 1 | t7_bla == 1, 'South Africa', 
                            ifelse(t2_we == 1 | t5_bre == 1 | t8_ble == 1, 'Estonia', 'Peru'))))
race <- race %>% 
  mutate(skin_binary = ifelse(control == 1, "Control",
                              ifelse(t1_wa == 1 | t2_we == 1 | t3_wl == 1, 'White', 'Dark')))
race <- race %>% 
  mutate(geography_binary = ifelse(control == 1, "Control",
                                   ifelse(t2_we == 1 | t5_bre == 1 |  t8_ble == 1, 'Western', 'Non-Western')))
race <- race %>% 
  rename(time = Duration..in.seconds., sex = Q1, age = Q2, ethnicity = Q3, ed = Q4, check = Q5, terrorist = Q6, supt = Q7, supt_time = Q7A_Page.Submit, leg = Q8, leg_time = Q8A_Page.Submit, responsible = Q9_1, responsible_time = Q9A_Page.Submit, open_ended = Q10, t1_party = Q11, t1_ethno1 = Q12_1, t1_ethno2 = Q12_2, t1_ethno3 = Q12_3, t1_ethno4 = Q12_4, t1_ethno5 = Q12_5, t1_ethno6 = Q12_6, t1_ethno7 = Q12_7, t1_force = Q13, t1_internationalism = Q14, t1_religion = Q15, t1_religiosity = Q16, t1_morality = Q17, t1_congress = Q18, t1_legality = Q19, t1_emotion1 = Q20_1, t1_emotion2 = Q20_2, t1_emotion3 = Q20_3, t1_emotion4 = Q20_4, t1_emotion5 = Q20_5, t1_emotion6 = Q20_6, t1_emotion7 = Q20_7, t1_emotion8 = Q20_8, t1_emotion9 = Q20_9, t1_race1 = Q21_1, t1_race2 = Q21_2, t1_race3 = Q21_3, t1_race4 = Q21_4, t1_race5 = Q21_5, t1_race6 = Q21_6)
race <- race %>% 
  rename(t2_party = Q22, t2_ethno1 = Q23_1, t2_ethno2 = Q23_2, t2_ethno3 = Q23_3, t2_ethno4 = Q23_4, t2_ethno5 = Q23_5, t2_ethno6 = Q23_6, t2_ethno7 = Q23_7, t2_force = Q24, t2_internationalism = Q25, t2_religion = Q26, t2_religiosity = Q27, t2_morality = Q28, t2_congress = Q29, t2_legality = Q30, t2_emotion1 = Q31_1, t2_emotion2 = Q31_2, t2_emotion3 = Q31_3, t2_emotion4 = Q31_4, t2_emotion5 = Q31_5, t2_emotion6 = Q31_6, t2_emotion7 = Q31_7, t2_emotion8 = Q31_8, t2_emotion9 = Q31_9, t2_race1 = Q32_1, t2_race2 = Q32_2, t2_race3 = Q32_3, t2_race4 = Q32_4, t2_race5 = Q32_5, t2_race6 = Q32_6)
race <- race %>% 
  rename(t3_party = Q33, t3_ethno1 = Q34_1, t3_ethno2 = Q34_2, t3_ethno3 = Q34_3, t3_ethno4 = Q34_4, t3_ethno5 = Q34_5, t3_ethno6 = Q34_6, t3_ethno7 = Q34_7, t3_force = Q35, t3_internationalism = Q36, t3_religion = Q37, t3_religiosity= Q38, t3_morality = Q39, t3_congress = Q40, t3_legality = Q41, t3_emotion1 = Q42_1, t3_emotion2 = Q42_2, t3_emotion3 = Q42_3, t3_emotion4 = Q42_4, t3_emotion5 = Q42_5, t3_emotion6 = Q42_6, t3_emotion7 = Q42_7, t3_emotion8 = Q42_8, t3_emotion9 = Q42_9, t3_race1 = Q43_1, t3_race2 = Q43_2, t3_race3 = Q43_3, t3_race4 = Q43_4, t3_race5 = Q43_5, t3_race6 = Q43_6)
race <- race %>% 
  rename(t4_party = Q44, t4_ethno1 = Q45_1, t4_ethno2 = Q45_2, t4_ethno3 = Q45_3, t4_ethno4 = Q45_4, t4_ethno5 = Q45_5, t4_ethno6 = Q45_6, t4_ethno7 = Q45_7, t4_force = Q46, t4_internationalism = Q47, t4_religion = Q48, t4_religiosity= Q49, t4_morality = Q50, t4_congress = Q51, t4_legality = Q52, t4_emotion1 = Q53_1, t4_emotion2 = Q53_2, t4_emotion3 = Q53_3, t4_emotion4 = Q53_4, t4_emotion5 = Q53_5, t4_emotion6 = Q53_6, t4_emotion7 = Q53_7, t4_emotion8 = Q53_8, t4_emotion9 = Q53_9, t4_race1 = Q54_1, t4_race2 = Q54_2, t4_race3 = Q54_3, t4_race4 = Q54_4, t4_race5 = Q54_5, t4_race6 = Q54_6)
race <- race %>% 
  rename(t5_party = Q55, t5_ethno1 = Q56_1, t5_ethno2 = Q56_2, t5_ethno3 = Q56_3, t5_ethno4 = Q56_4, t5_ethno5 = Q56_5, t5_ethno6 = Q56_6, t5_ethno7 = Q56_7, t5_force = Q57, t5_internationalism = Q58, t5_religion = Q59, t5_religiosity= Q60, t5_morality = Q61, t5_congress = Q62, t5_legality = Q63, t5_emotion1 = Q64_1, t5_emotion2 = Q64_2, t5_emotion3 = Q64_3, t5_emotion4 = Q64_4, t5_emotion5 = Q64_5, t5_emotion6 = Q64_6, t5_emotion7 = Q64_7, t5_emotion8 = Q64_8, t5_emotion9 = Q64_9, t5_race1 = Q65_1, t5_race2 = Q65_2, t5_race3 = Q65_3, t5_race4 = Q65_4, t5_race5 = Q65_5, t5_race6 = Q65_6)
race <- race %>% 
  rename(t6_party = Q66, t6_ethno1 = Q67_1, t6_ethno2 = Q67_2, t6_ethno3 = Q67_3, t6_ethno4 = Q67_4, t6_ethno5 = Q67_5, t6_ethno6 = Q67_6, t6_ethno7 = Q67_7, t6_force = Q68, t6_internationalism = Q69, t6_religion = Q70, t6_religiosity= Q71, t6_morality = Q72, t6_congress = Q73, t6_legality = Q74, t6_emotion1 = Q75_1, t6_emotion2 = Q75_2, t6_emotion3 = Q75_3, t6_emotion4 = Q75_4, t6_emotion5 = Q75_5, t6_emotion6 = Q75_6, t6_emotion7 = Q75_7, t6_emotion8 = Q75_8, t6_emotion9 = Q75_9, t6_race1 = Q76_1, t6_race2 = Q76_2, t6_race3 = Q76_3, t6_race4 = Q76_4, t6_race5 = Q76_5, t6_race6 = Q76_6) 
race <- race %>% 
  rename(t7_party = Q77, t7_ethno1 = Q78_1, t7_ethno2 = Q78_2, t7_ethno3 = Q78_3, t7_ethno4 = Q78_4, t7_ethno5 = Q78_5, t7_ethno6 = Q78_6, t7_ethno7 = Q78_7, t7_force = Q79, t7_internationalism = Q80, t7_religion = Q81, t7_religiosity  = Q82, t7_morality = Q83, t7_congress = Q84, t7_legality = Q85, t7_emotion1 = Q86_1, t7_emotion2 = Q86_2, t7_emotion3 = Q86_3, t7_emotion4 = Q86_4, t7_emotion5 = Q86_5, t7_emotion6 = Q86_6, t7_emotion7 = Q86_7, t7_emotion8 = Q86_8, t7_emotion9 = Q86_9, t7_race1 = Q87_1, t7_race2 = Q87_2, t7_race3 = Q87_3, t7_race4 = Q87_4, t7_race5 = Q87_5, t7_race6 = Q87_6) 
race <- race %>% 
  rename(t8_party = Q88, t8_ethno1 = Q89_1, t8_ethno2 = Q89_2, t8_ethno3 = Q89_3, t8_ethno4 = Q89_4, t8_ethno5 = Q89_5, t8_ethno6 = Q89_6, t8_ethno7 = Q89_7, t8_force = Q90, t8_internationalism = Q91, t8_religion = Q92, t8_religiosity = Q93, t8_morality = Q94, t8_congress = Q95, t8_legality = Q96, t8_emotion1 = Q97_1, t8_emotion2 = Q97_2, t8_emotion3 = Q97_3, t8_emotion4 = Q97_4, t8_emotion5 = Q97_5, t8_emotion6 = Q97_6, t8_emotion7 = Q97_7, t8_emotion8 = Q97_8, t8_emotion9 = Q97_9, t8_race1 = Q98_1, t8_race2 = Q98_2, t8_race3 = Q98_3, t8_race4 = Q98_4, t8_race5 = Q98_5, t8_race6 = Q98_6)  
race <- race %>% 
  rename(t9_party = Q99, t9_ethno1 = Q100_1, t9_ethno2 = Q100_2, t9_ethno3 = Q100_3, t9_ethno4 = Q100_4, t9_ethno5 = Q100_5, t9_ethno6 = Q100_6, t9_ethno7 = Q100_7, t9_force = Q101, t9_internationalism = Q102, t9_religion = Q103, t9_religiosity = Q104, t9_morality = Q105, t9_congress = Q106, t9_legality = Q107, t9_emotion1 = Q108_1, t9_emotion2 = Q108_2, t9_emotion3 = Q108_3, t9_emotion4 = Q108_4, t9_emotion5 = Q108_5, t9_emotion6 = Q108_6, t9_emotion7 = Q108_7, t9_emotion8 = Q108_8, t9_emotion9 = Q108_9, t9_race1 = Q109_1, t9_race2 = Q109_2, t9_race3 = Q109_3, t9_race4 = Q109_4, t9_race5 = Q109_5, t9_race6 = Q109_6)  
race <- race %>% 
  rename(ctl_party = Q110, ctl_ethno1 = Q111_1, ctl_ethno2 = Q111_2, ctl_ethno3 = Q111_3, ctl_ethno4 = Q111_4, ctl_ethno5 = Q111_5, ctl_ethno6 = Q111_6, ctl_ethno7 = Q111_7, ctl_force = Q112, ctl_internationalism = Q113, ctl_religion = Q114, ctl_religiosity  = Q115, ctl_morality = Q116, ctl_congress = Q117, ctl_legality = Q118, ctl_emotion1 = Q119_1, ctl_emotion2 = Q119_2, ctl_emotion3 = Q119_3, ctl_emotion4 = Q119_4, ctl_emotion5 = Q119_5, ctl_emotion6 = Q119_6, ctl_emotion7 = Q119_7, ctl_emotion8 = Q119_8, ctl_emotion9 = Q119_9, ctl_race1 = Q120_1, ctl_race2 = Q120_2, ctl_race3 = Q120_3, ctl_race4 = Q120_4, ctl_race5 = Q120_5, ctl_race6 = Q120_6) 
race <- race %>% 
  rename(racist = Q121, income = Q122, state = Q123, military = Q124, years = Q125, branch = Q126, sof = Q127, rank = Q128, deployments = Q129, combat = Q130)
race <- race %>% mutate(across(!open_ended & !group & !skin & !geography & !skin_binary & !geography_binary, as.numeric))
questions <- questions %>% 
  mutate(group = `Respondent.Group`,
         control = case_when(group == 'Control Scenario' ~ 1,  
                             group != 'Control Scenario' ~ 0),
         t1_wa = case_when(group == 'Scenario #1, Treatment' ~ 1,
                        group != 'Scenario #1, Treatment' ~ 0),
         t2_we = case_when(group == 'Scenario #2, Treatment' ~ 1,
                        group != 'Scenario #2, Treatment' ~ 0),
         t3_wl = case_when(group == 'Scenario #3, Treatment' ~ 1,
                        group != 'Scenario #3, Treatment' ~ 0),
         t4_bra = case_when(group == 'Scenario #4, Treatment' ~ 1,
                        group != 'Scenario #4, Treatment' ~ 0),
         t5_bre = case_when(group == 'Scenario #5, Treatment' ~ 1,
                        group != 'Scenario #5, Treatment' ~ 0),
         t6_brl = case_when(group == 'Scenario #6, Treatment' ~ 1,
                        group != 'Scenario #6, Treatment' ~ 0),
         t7_bla = case_when(group == 'Scenario #7, Treatment' ~ 1,
                        group != 'Scenario #7, Treatment' ~ 0),
         t8_ble = case_when(group == 'Scenario #8, Treatment' ~ 1,
                        group != 'Scenario #8, Treatment' ~ 0),
         t9_bll = case_when(group == 'Scenario #9, Treatment' ~ 1,
                        group != 'Scenario #9, Treatment' ~ 0))
questions <- questions %>% 
  select(-`Respondent.Group`) 
questions <- questions %>% 
  mutate(skin = ifelse(control == 1, "Control",
                       ifelse(t1_wa == 1 | t2_we == 1 | t3_wl == 1, 'White', 
                       ifelse(t4_bra == 1 | t5_bre == 1 | t6_brl == 1, 'Brown', 'Black'))))
questions <- questions %>% 
  mutate(geography = ifelse(control == 1, "Control",
                            ifelse(t1_wa == 1 | t4_bra == 1 | t7_bla == 1, 'South Africa', 
                            ifelse(t2_we == 1 | t5_bre == 1 | t8_ble == 1, 'Estonia', 'Peru'))))
questions <- questions %>% 
  mutate(skin_binary = ifelse(control == 1, "Control",
                              ifelse(t1_wa == 1 | t2_we == 1 | t3_wl == 1, 'White', 'Dark')))
questions <- questions %>% 
  mutate(geography_binary = ifelse(control == 1, "Control",
                                   ifelse(t2_we == 1 | t5_bre == 1 |  t8_ble == 1, 'Western', 'Non-Western')))
questions <- questions %>% 
  rename(supt = Q7, leg = Q8, answer = Q10, score = Open) %>%
  mutate(score = as.numeric(score))

```

### 1) Summary Statistics: 

```{r summary, echo=FALSE, eval=TRUE, message=FALSE}
race_table <- race %>% select(sex, age, ethnicity, ed, income, group) %>% filter(sex != 3)
race_table <- race_table %>% rename(Sex = sex, Age = age, Ethnicity = ethnicity, Education = ed, Income = income)
race_table$Sex <- ifelse(race_table$Sex==1, "Men", 
                         ifelse(race_table$Sex==2, "Women", NA))
race_table$Age <- ifelse(race_table$Age==1, "Under 18", 
                          ifelse(race_table$Age==2, "19-25",
                                 ifelse(race_table$Age==3, "26-35", 
                                        ifelse(race_table$Age==4, "36-45",
                                               ifelse(race_table$Age==5, "46-55", 
                                                      ifelse(race_table$Age==6, "56-65",
                                                             ifelse(race_table$Age==7, "Over 66",NA)))))))

race_table$Ethnicity <- ifelse(race_table$Ethnicity==1, "American Indian, Alaskan Native", 
                          ifelse(race_table$Ethnicity==2, "Asian",
                                 ifelse(race_table$Ethnicity==3, "Black", 
                                        ifelse(race_table$Ethnicity==4, "Hispanic",
                                               ifelse(race_table$Ethnicity==5, "Native Hawaiian, Other Pacific Islander", 
                                                      ifelse(race_table$Ethnicity==6, "White, Non-Hispanic", 
                                                             ifelse(race_table$Ethnicity==7, "Other",NA)))))))
race_table$Education <- ifelse(race_table$Education==1, "Some High School", 
                          ifelse(race_table$Education==2, "High School",
                                 ifelse(race_table$Education==3, "Some College", 
                                        ifelse(race_table$Education==4, "2-Year Degree",
                                               ifelse(race_table$Education==5, "4-Year Degree", 
                                                      ifelse(race_table$Education==6, "Advanced Degree", NA))))))
race_table$Income <- ifelse(race_table$Income==1, "< $9,999", 
                          ifelse(race_table$Income==2, "$10,000-$24,999",
                                 ifelse(race_table$Income==3, "$25,000-$49,999", 
                                        ifelse(race_table$Income==4, "$50,000-$74,999",
                                               ifelse(race_table$Income==5, "$75,000-$99,999", 
                                                      ifelse(race_table$Income==6, "> $100,000", NA))))))
race_table$group <- ifelse(race_table$group=='Control Scenario', "CTL", 
                          ifelse(race_table$group=='Scenario #1, Treatment', "T1 (WH/SA)",
                                 ifelse(race_table$group=='Scenario #2, Treatment', "T2 (WH/EE)",
                                        ifelse(race_table$group=='Scenario #3, Treatment', "T3 (WH/PE)",
                                               ifelse(race_table$group=='Scenario #4, Treatment', "T4 (BR/SA)",
                                                      ifelse(race_table$group=='Scenario #5, Treatment', "T5 (BR/EE)",
                                                              ifelse(race_table$group=='Scenario #6, Treatment', "T6 (BR/PE)",
                                                                      ifelse(race_table$group=='Scenario #7, Treatment', "T7 (BL/SA)",
                                                                              ifelse(race_table$group=='Scenario #8, Treatment', "T8 (BL/EE)",
                                                                                      ifelse(race_table$group=='Scenario #9, Treatment', "T9 (BL/PE)", NA ))))))))))

theme_gtsummary_journal(journal = "qjecon")
theme_gtsummary_compact()
race_table %>%
  mutate(Sex = factor(Sex, levels = c ("Men", 
                                       "Women")))%>%
  mutate(Age = factor(Age, levels = c ("Under 18", 
                                       "19-25",
                                       "26-35",
                                       "36-45",
                                       "46-55",
                                       "56-65",
                                       "Over 66"))) %>%
  mutate(Ethnicity = factor(Ethnicity, levels = c ("American Indian, Alaskan Native", 
                                                  "Asian",
                                                  "Black",
                                                  "Hispanic", 
                                                  "Native Hawaiian, Other Pacific Islander", 
                                                  "White, Non-Hispanic",
                                                  "Other"))) %>% 
  mutate(Education = factor(Education, levels = c ("Some High School", 
                                                  "High School",
                                                  "Some College",
                                                  "2-Year Degree", 
                                                  "4-Year Degree", 
                                                  "Advanced Degree"))) %>% 
  mutate(Income = factor(Income, levels = c("< $9,999", 
                                            "$10,000-$24,999",
                                            "$25,000-$49,999",
                                            "$50,000-$74,999", 
                                            "$75,000-$99,999", 
                                            "> $100,000"))) %>% 
  tbl_summary(by = group) %>% 
  add_overall() %>%
  modify_header(label ~ "**Group**") %>%
  modify_footnote(update = everything() ~ NA) %>%
  bold_labels
```

### 2) Public Support by Experimental Groups: 

#### a) T-Tests for Experimental Groups: 

```{r support ttests1, echo=FALSE, eval=TRUE }
t.test(ctl$supt,t1$supt)
t.test(ctl$supt,t2$supt)
t.test(ctl$supt,t3$supt)
t.test(ctl$supt,t4$supt)
t.test(ctl$supt,t5$supt)
t.test(ctl$supt,t6$supt)
t.test(ctl$supt,t7$supt)
t.test(ctl$supt,t8$supt)
t.test(ctl$supt,t9$supt)
t.test(t4$supt,t3$supt)
t.test(t2$supt,t3$supt)
pwc <- race %>% pairwise_t_test(supt ~ group, p.adjust.method = "bonferroni")
```

#### b) T-Tests between Skin Colors: 

```{r support ttests2, echo=FALSE, eval=TRUE }
t.test(white$supt,brown$supt)
t.test(white$supt,black$supt)
```

#### c) T-Tests between Countries: 

```{r support ttests3, echo=FALSE, eval=TRUE }
t.test(ee$supt,pe$supt)
t.test(ee$supt,sa$supt)
t.test(sa$supt,pe$supt)
pwc <- race %>% pairwise_t_test(supt ~ geography, p.adjust.method = "bonferroni")
```

#### d) T-Tests between Regions: 

```{r support ttests4, echo=FALSE, eval=TRUE }
t.test(west$supt,non_west$supt)
t.test(west$supt,non_west2$supt)
```

#### e) Support Graph: 

```{r support by treatment groups, echo=FALSE}
support_summary <- race %>% filter (group != "Control Scenario") %>%
  group_by(group) %>%
  summarise(n=n(),
            sd = sd(supt, na.rm = TRUE),
            se = se(supt, na.rm = TRUE),
            ic = se*qt((1-0.05)/2 + .5, n-1),
            supt = mean(supt))
ggplot(support_summary, aes(group, supt)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = supt-ic, ymax = supt+ic), width = 0.2) +
  # geom_errorbar(aes(ymin = supt, ymax = supt+sd), width = 0.2) +
  scale_x_discrete(labels=c("White, South Africa**",
                            "White, Estonia", 
                            "White, Peru***", 
                            "Brown, South Africa", 
                            "Brown, Estonia**",
                            "Brown, Peru**",
                            "Black, South Africa**",
                            "Black, Estonia**",
                            "Black, Peru**")) +
  scale_y_continuous(limits = c(3,4)) +  
  geom_hline(yintercept = mean(ctl$supt), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("Mean Support for the U.S. Drone Strike") +
  xlab("Experimental Condition") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")
```

### 3) Isolating Treatment Effects:

```{r isolated support, echo=FALSE, eval=TRUE, include=TRUE}
support_isolated_summary <- race %>% filter(skin != 'Control') %>% 
  group_by(skin, geography) %>%
  summarise(n=n(),
            sd = sd(supt, na.rm = TRUE),
            se = se(supt, na.rm = TRUE),
            ic = se*qt((1-0.05)/2 + .5, n-1),
            supt = mean(supt))
support_isolated_summary
ggplot(support_isolated_summary, aes(geography, supt)) +
  geom_col(aes(fill = skin), position = position_dodge(0.8), width = 0.7) +
  geom_errorbar(aes(ymin = supt-ic, ymax = supt+ic, group = skin), width = 0.2, position = position_dodge(0.8)) +
  scale_fill_manual(values = c("grey90", "grey70", "grey50")) +
  theme_bw() +
  labs(fill = "Skin Color") +
  ylab("Mean Support of the U.S. Drone Strike") +
  xlab("Geographic Setting") +
  # theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")
```

```{r isolated support2, echo=FALSE, eval=TRUE, include=TRUE}
support_isolated_summary2 <- race %>% filter(skin_binary != 'Control') %>% 
  group_by(skin_binary, geography_binary) %>%
  summarise(n=n(),
            sd = sd(supt, na.rm = TRUE),
            se = se(supt, na.rm = TRUE),
            ic = se*qt((1-0.05)/2 + .5, n-1),
            supt = mean(supt))
support_isolated_summary2
ggplot(support_isolated_summary2, aes(geography_binary, supt)) +
  geom_col(aes(fill = skin_binary), position = position_dodge(0.8), width = 0.7) +
  geom_errorbar(aes(ymin = supt-ic, ymax = supt+ic, group = skin_binary), width = 0.2, position = position_dodge(0.8)) +
  scale_fill_manual(values = c("grey90", "grey70", "grey50")) +
  theme_bw() +
  labs(fill = "Skin Color") +
  ylab("Mean Support for the U.S. Drone Strike") +
  xlab("Geographic Setting") +
  # theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")
```

### 4) Dataset for Analysis of Emotions and Regression Analysis: 

```{r update dataset, echo=FALSE}
race <- race %>%  
  mutate(party_score = ifelse(control == 1, ctl_party,  
                              ifelse(t1_wa == 1, t1_party,  
                                     ifelse(t2_we == 1, t2_party,
                                            ifelse(t3_wl == 1, t3_party,
                                                   ifelse(t4_bra == 1, t4_party,
                                                          ifelse(t5_bre == 1, t5_party, 
                                                                 ifelse(t6_brl == 1, t6_party, 
                                                                        ifelse(t7_bla == 1, t7_party, 
                                                                               ifelse(t8_ble == 1, t8_party, 
                                                                                      ifelse(t9_bll == 1, t9_party,NA)))))))))))
race <- race %>%  
  mutate(force_score = ifelse(control == 1, ctl_force,  
                              ifelse(t1_wa == 1, t1_force,  
                                     ifelse(t2_we == 1, t2_force,
                                            ifelse(t3_wl == 1, t3_force,
                                                   ifelse(t4_bra == 1, t4_force,
                                                          ifelse(t5_bre == 1, t5_force, 
                                                                 ifelse(t6_brl == 1, t6_force, 
                                                                        ifelse(t7_bla == 1, t7_force, 
                                                                               ifelse(t8_ble == 1, t8_force, 
                                                                                      ifelse(t9_bll == 1, t9_force,NA)))))))))))
race <- race %>%  
  mutate(internationalism_score = ifelse(control == 1, ctl_internationalism,  
                              ifelse(t1_wa == 1, t1_internationalism,  
                                     ifelse(t2_we == 1, t2_internationalism,
                                            ifelse(t3_wl == 1, t3_internationalism,
                                                   ifelse(t4_bra == 1, t4_internationalism,
                                                          ifelse(t5_bre == 1, t5_internationalism, 
                                                                 ifelse(t6_brl == 1, t6_internationalism, 
                                                                        ifelse(t7_bla == 1, t7_internationalism, 
                                                                               ifelse(t8_ble == 1, t8_internationalism, 
                                                                                      ifelse(t9_bll == 1, t9_internationalism,NA)))))))))))
race <- race %>%  
  mutate(religiosity_score = ifelse(control == 1, ctl_religiosity ,  
                              ifelse(t1_wa == 1, t1_religiosity ,  
                                     ifelse(t2_we == 1, t2_religiosity , 
                                            ifelse(t3_wl == 1, t3_religiosity ,
                                                   ifelse(t4_bra == 1, t4_religiosity ,
                                                          ifelse(t5_bre == 1, t5_religiosity , 
                                                                 ifelse(t6_brl == 1, t6_religiosity , 
                                                                        ifelse(t7_bla == 1, t7_religiosity , 
                                                                               ifelse(t8_ble == 1, t8_religiosity , 
                                                                                      ifelse(t9_bll == 1, t9_religiosity,NA)))))))))))
race <- race %>%  
  mutate(morality_score = ifelse(control == 1, ctl_morality,  
                              ifelse(t1_wa == 1, t1_morality,  
                                     ifelse(t2_we == 1, t2_morality, 
                                            ifelse(t3_wl == 1, t3_morality,
                                                   ifelse(t4_bra == 1, t4_morality,
                                                          ifelse(t5_bre == 1, t5_morality, 
                                                                 ifelse(t6_brl == 1, t6_morality, 
                                                                        ifelse(t7_bla == 1, t7_morality, 
                                                                               ifelse(t8_ble == 1, t8_morality, 
                                                                                      ifelse(t9_bll == 1, t9_morality,NA)))))))))))
race <- race %>%  
  mutate(congress_score = ifelse(control == 1, ctl_congress,  
                              ifelse(t1_wa == 1, t1_congress,  
                                     ifelse(t2_we == 1, t2_congress, 
                                            ifelse(t3_wl == 1, t3_congress,
                                                   ifelse(t4_bra == 1, t4_congress,
                                                          ifelse(t5_bre == 1, t5_congress, 
                                                                 ifelse(t6_brl == 1, t6_congress, 
                                                                        ifelse(t7_bla == 1, t7_congress, 
                                                                               ifelse(t8_ble == 1, t8_congress, 
                                                                                      ifelse(t9_bll == 1, t9_congress,NA)))))))))))
race <- race %>%  
  mutate(legality_score = ifelse(control == 1, ctl_legality,  
                              ifelse(t1_wa == 1, t1_legality,  
                                     ifelse(t2_we == 1, t2_legality, 
                                            ifelse(t3_wl == 1, t3_legality,
                                                   ifelse(t4_bra == 1, t4_legality,
                                                          ifelse(t5_bre == 1, t5_legality, 
                                                                 ifelse(t6_brl == 1, t6_legality, 
                                                                        ifelse(t7_bla == 1, t7_legality, 
                                                                               ifelse(t8_ble == 1, t8_legality, 
                                                                                      ifelse(t9_bll == 1, t9_legality,NA)))))))))))
race <- race %>% 
  mutate(ethno_score = ifelse(control == 1, ((ctl_ethno1+ctl_ethno2+ctl_ethno3+ctl_ethno4+ctl_ethno5+ctl_ethno6+ctl_ethno7)/7), 
                       ifelse(t1_wa == 1, ((t1_ethno1+t1_ethno2+t1_ethno3+t1_ethno4+t1_ethno5+t1_ethno6+t1_ethno7)/7), 
                       ifelse(t2_we == 1, ((t2_ethno1+t2_ethno2+t2_ethno3+t2_ethno4+t2_ethno5+t2_ethno6+t2_ethno7)/7), 
                       ifelse(t3_wl == 1, ((t3_ethno1+t3_ethno2+t3_ethno3+t3_ethno4+t3_ethno5+t3_ethno6+t3_ethno7)/7), 
                       ifelse(t4_bra == 1, ((t4_ethno1+t4_ethno2+t4_ethno3+t4_ethno4+t4_ethno5+t4_ethno6+t4_ethno7)/7),
                       ifelse(t5_bre == 1, ((t5_ethno1+t5_ethno2+t5_ethno3+t5_ethno4+t5_ethno5+t5_ethno6+t5_ethno7)/7), 
                       ifelse(t6_brl == 1, ((t6_ethno1+t6_ethno2+t6_ethno3+t6_ethno4+t6_ethno5+t6_ethno6+t6_ethno7)/7),
                       ifelse(t7_bla == 1, ((t7_ethno1+t7_ethno2+t7_ethno3+t7_ethno4+t7_ethno5+t7_ethno6+t7_ethno7)/7),
                       ifelse(t8_ble == 1, ((t8_ethno1+t8_ethno2+t8_ethno3+t8_ethno4+t8_ethno5+t8_ethno6+t8_ethno7)/7),
                       ifelse(t9_bll == 1, ((t9_ethno1+t9_ethno2+t9_ethno3+t9_ethno4+t9_ethno5+t9_ethno6+t9_ethno7)/7),NA)))))))))))
race <- race %>% 
  mutate(emotion_score = 
           ifelse(control == 1, ((ctl_emotion1+ctl_emotion2+ctl_emotion3+ctl_emotion4+ctl_emotion5+ctl_emotion6+ctl_emotion7+ctl_emotion8+ctl_emotion9)/9), 
           ifelse(t1_wa == 1, ((t1_emotion1+t1_emotion2+t1_emotion3+t1_emotion4+t1_emotion5+t1_emotion6+t1_emotion7+t1_emotion8+t1_emotion9)/9), 
           ifelse(t2_we == 1, ((t2_emotion1+t2_emotion2+t2_emotion3+t2_emotion4+t2_emotion5+t2_emotion6+t2_emotion7+t2_emotion8+t2_emotion9)/9),
           ifelse(t3_wl == 1, ((t3_emotion1+t3_emotion2+t3_emotion3+t3_emotion4+t3_emotion5+t3_emotion6+t3_emotion7+t3_emotion8+t3_emotion9)/9),
           ifelse(t4_bra == 1, ((t4_emotion1+t4_emotion2+t4_emotion3+t4_emotion4+t4_emotion5+t4_emotion6+t4_emotion7+t4_emotion8+t4_emotion9)/9),
           ifelse(t5_bre == 1, ((t5_emotion1+t5_emotion2+t5_emotion3+t5_emotion4+t5_emotion5+t5_emotion6+t5_emotion7+t5_emotion8+t5_emotion9)/9), 
           ifelse(t6_brl == 1, ((t6_emotion1+t6_emotion2+t6_emotion3+t6_emotion4+t6_emotion5+t6_emotion6+t6_emotion7+t6_emotion8+t6_emotion9)/9),
           ifelse(t7_bla == 1, ((t7_emotion1+t7_emotion2+t7_emotion3+t7_emotion4+t7_emotion5+t7_emotion6+t7_emotion7+t7_emotion8+t7_emotion9)/9),
           ifelse(t8_ble == 1, ((t8_emotion1+t8_emotion2+t8_emotion3+t8_emotion4+t8_emotion5+t8_emotion6+t8_emotion7+t8_emotion8+t8_emotion9)/9),
           ifelse(t9_bll == 1, ((t9_emotion1+t9_emotion2+t9_emotion3+t9_emotion4+t9_emotion5+t9_emotion6+t9_emotion7+t9_emotion8+t9_emotion9)/9),NA)))))))))))
race <- race %>% 
  mutate(race_score = 
           ifelse(control == 1, ((ctl_race1+ctl_race2+ctl_race3+ctl_race4+ctl_race5+ctl_race6)), 
           ifelse(t1_wa == 1, ((t1_race1+t1_race2+t1_race3+t1_race4+t1_race5+t1_race6)), 
           ifelse(t2_we == 1, ((t2_race1+t2_race2+t2_race3+t2_race4+t2_race5+t2_race6)),
           ifelse(t3_wl == 1, ((t3_race1+t3_race2+t3_race3+t3_race4+t3_race5+t3_race6)),
           ifelse(t4_bra == 1, ((t4_race1+t4_race2+t4_race3+t4_race4+t4_race5+t4_race6)),
           ifelse(t5_bre == 1, ((t5_race1+t5_race2+t5_race3+t5_race4+t5_race5+t5_race6)), 
           ifelse(t6_brl == 1, ((t6_race1+t6_race2+t6_race3+t6_race4+t6_race5+t6_race6)),
           ifelse(t7_bla == 1, ((t7_race1+t7_race2+t7_race3+t7_race4+t7_race5+t7_race6)),
           ifelse(t8_ble == 1, ((t8_race1+t8_race2+t8_race3+t8_race4+t8_race5+t8_race6)),
           ifelse(t9_bll == 1, ((t9_race1+t9_race2+t9_race3+t9_race4+t9_race5+t9_race6)),NA)))))))))))
                  
race_regress <- race %>% select(time,sex,age,ed,supt,ethnicity,leg,responsible,income,military,group,ethno_score,emotion_score,party_score,force_score,
                                internationalism_score,religiosity_score,morality_score,congress_score,legality_score,racist, race_score, skin,
                                geography,skin_binary, geography_binary,terrorist,control,t1_wa,t2_we,t3_wl,t4_bra,t5_bre,t6_brl,t7_bla,t8_ble,t9_bll) %>% 
                                filter(party_score != 8)
```

### 5) Analysis of Emotions:

```{r emotion,echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
control_emotion <- race %>% select(ctl_emotion1,ctl_emotion2,ctl_emotion3,ctl_emotion4,ctl_emotion5,ctl_emotion6,ctl_emotion7,ctl_emotion8,ctl_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "ctl_emotion1", "anxiety" = "ctl_emotion2",
                       "worry" = "ctl_emotion3", "anger" = "ctl_emotion4",
                       "bitter" = "ctl_emotion5", "resentful" = "ctl_emotion6",
                       "disgust" = "ctl_emotion7", "hate" = "ctl_emotion8",
                       "contempt"="ctl_emotion9") 
t1_emotion <- race %>% select(t1_emotion1,t1_emotion2,t1_emotion3,t1_emotion4,t1_emotion5,t1_emotion6,t1_emotion7,t1_emotion8,t1_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t1_emotion1", "anxiety" = "t1_emotion2",
                       "worry" = "t1_emotion3", "anger" = "t1_emotion4",
                       "bitter" = "t1_emotion5", "resentful" = "t1_emotion6",
                       "disgust" = "t1_emotion7", "hate" = "t1_emotion8",
                       "contempt"="t1_emotion9") 
t2_emotion <- race %>% select(t2_emotion1,t2_emotion2,t2_emotion3,t2_emotion4,t2_emotion5,t2_emotion6,t2_emotion7,t2_emotion8,t2_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t2_emotion1", "anxiety" = "t2_emotion2",
                       "worry" = "t2_emotion3", "anger" = "t2_emotion4",
                       "bitter" = "t2_emotion5", "resentful" = "t2_emotion6",
                       "disgust" = "t2_emotion7", "hate" = "t2_emotion8",
                       "contempt"="t2_emotion9") 
t3_emotion <- race %>% select(t3_emotion1,t3_emotion2,t3_emotion3,t3_emotion4,t3_emotion5,t3_emotion6,t3_emotion7,t3_emotion8,t3_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t3_emotion1", "anxiety" = "t3_emotion2",
                       "worry" = "t3_emotion3", "anger" = "t3_emotion4",
                       "bitter" = "t3_emotion5", "resentful" = "t3_emotion6",
                       "disgust" = "t3_emotion7", "hate" = "t3_emotion8",
                       "contempt"="t3_emotion9") 
t4_emotion <- race %>% select(t4_emotion1,t4_emotion2,t4_emotion3,t4_emotion4,t4_emotion5,t4_emotion6,t4_emotion7,t4_emotion8,t4_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t4_emotion1", "anxiety" = "t4_emotion2",
                       "worry" = "t4_emotion3", "anger" = "t4_emotion4",
                       "bitter" = "t4_emotion5", "resentful" = "t4_emotion6",
                       "disgust" = "t4_emotion7", "hate" = "t4_emotion8",
                       "contempt"="t4_emotion9") 
t5_emotion <- race %>% select(t5_emotion1,t5_emotion2,t5_emotion3,t5_emotion4,t5_emotion5,t5_emotion6,t5_emotion7,t5_emotion8,t5_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t5_emotion1", "anxiety" = "t5_emotion2",
                       "worry" = "t5_emotion3", "anger" = "t5_emotion4",
                       "bitter" = "t5_emotion5", "resentful" = "t5_emotion6",
                       "disgust" = "t5_emotion7", "hate" = "t5_emotion8",
                       "contempt"="t5_emotion9") 
t6_emotion <- race %>% select(t6_emotion1,t6_emotion2,t6_emotion3,t6_emotion4,t6_emotion5,t6_emotion6,t6_emotion7,t6_emotion8,t6_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t6_emotion1", "anxiety" = "t6_emotion2",
                       "worry" = "t6_emotion3", "anger" = "t6_emotion4",
                       "bitter" = "t6_emotion5", "resentful" = "t6_emotion6",
                       "disgust" = "t6_emotion7", "hate" = "t6_emotion8",
                       "contempt"="t6_emotion9") 
t7_emotion <- race %>% select(t7_emotion1,t7_emotion2,t7_emotion3,t7_emotion4,t7_emotion5,t7_emotion6,t7_emotion7,t7_emotion8,t7_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t7_emotion1", "anxiety" = "t7_emotion2",
                       "worry" = "t7_emotion3", "anger" = "t7_emotion4",
                       "bitter" = "t7_emotion5", "resentful" = "t7_emotion6",
                       "disgust" = "t7_emotion7", "hate" = "t7_emotion8",
                       "contempt"="t7_emotion9") 
t8_emotion <- race %>% select(t8_emotion1,t8_emotion2,t8_emotion3,t8_emotion4,t8_emotion5,t8_emotion6,t8_emotion7,t8_emotion8,t8_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t8_emotion1", "anxiety" = "t8_emotion2",
                       "worry" = "t8_emotion3", "anger" = "t8_emotion4",
                       "bitter" = "t8_emotion5", "resentful" = "t8_emotion6",
                       "disgust" = "t8_emotion7", "hate" = "t8_emotion8",
                       "contempt"="t8_emotion9") 
t9_emotion <- race %>% select(t9_emotion1,t9_emotion2,t9_emotion3,t9_emotion4,t9_emotion5,t9_emotion6,t9_emotion7,t9_emotion8,t9_emotion9,skin,geography,group) %>% 
  drop_na() %>% rename("fear" = "t9_emotion1", "anxiety" = "t9_emotion2",
                       "worry" = "t9_emotion3", "anger" = "t9_emotion4",
                       "bitter" = "t9_emotion5", "resentful" = "t9_emotion6",
                       "disgust" = "t9_emotion7", "hate" = "t9_emotion8",
                       "contempt"="t9_emotion9") 
overall_emotion <- rbind(control_emotion,t1_emotion,t2_emotion,t3_emotion,t4_emotion,t5_emotion,t6_emotion,t7_emotion, t8_emotion,t9_emotion)

mean(control_emotion$fear)
t.test(control_emotion$fear,t1_emotion$fear)
t.test(control_emotion$fear,t2_emotion$fear)
t.test(control_emotion$fear,t3_emotion$fear)
t.test(control_emotion$fear,t4_emotion$fear)
t.test(control_emotion$fear,t5_emotion$fear)
t.test(control_emotion$fear,t6_emotion$fear)
t.test(control_emotion$fear,t7_emotion$fear)
t.test(control_emotion$fear,t8_emotion$fear)
t.test(control_emotion$fear,t9_emotion$fear)

mean(control_emotion$anxiety)
t.test(control_emotion$anxiety,t1_emotion$anxiety)
t.test(control_emotion$anxiety,t2_emotion$anxiety)
t.test(control_emotion$anxiety,t3_emotion$anxiety)
t.test(control_emotion$anxiety,t4_emotion$anxiety)
t.test(control_emotion$anxiety,t5_emotion$anxiety)
t.test(control_emotion$anxiety,t6_emotion$anxiety)
t.test(control_emotion$anxiety,t7_emotion$anxiety)
t.test(control_emotion$anxiety,t8_emotion$anxiety)
t.test(control_emotion$anxiety,t9_emotion$anxiety)

mean(control_emotion$worry)
t.test(control_emotion$worry,t1_emotion$worry)
t.test(control_emotion$worry,t2_emotion$worry)
t.test(control_emotion$worry,t3_emotion$worry)
t.test(control_emotion$worry,t4_emotion$worry)
t.test(control_emotion$worry,t5_emotion$worry)
t.test(control_emotion$worry,t6_emotion$worry)
t.test(control_emotion$worry,t7_emotion$worry)
t.test(control_emotion$worry,t8_emotion$worry)
t.test(control_emotion$worry,t9_emotion$worry)

mean(control_emotion$anger)
t.test(control_emotion$anger,t1_emotion$anger)
t.test(control_emotion$anger,t2_emotion$anger)
t.test(control_emotion$anger,t3_emotion$anger)
t.test(control_emotion$anger,t4_emotion$anger)
t.test(control_emotion$anger,t5_emotion$anger)
t.test(control_emotion$anger,t6_emotion$anger)
t.test(control_emotion$anger,t7_emotion$anger)
t.test(control_emotion$anger,t8_emotion$anger)
t.test(control_emotion$anger,t9_emotion$anger)

mean(control_emotion$bitter)
t.test(control_emotion$bitter,t1_emotion$bitter)
t.test(control_emotion$bitter,t2_emotion$bitter)
t.test(control_emotion$bitter,t3_emotion$bitter)
t.test(control_emotion$bitter,t4_emotion$bitter)
t.test(control_emotion$bitter,t5_emotion$bitter)
t.test(control_emotion$bitter,t6_emotion$bitter)
t.test(control_emotion$bitter,t7_emotion$bitter)
t.test(control_emotion$bitter,t8_emotion$bitter)
t.test(control_emotion$bitter,t9_emotion$bitter)

mean(control_emotion$resentful)
t.test(control_emotion$resentful,t1_emotion$resentful)
t.test(control_emotion$resentful,t2_emotion$resentful)
t.test(control_emotion$resentful,t3_emotion$resentful)
t.test(control_emotion$resentful,t4_emotion$resentful)
t.test(control_emotion$resentful,t5_emotion$resentful)
t.test(control_emotion$resentful,t6_emotion$resentful)
t.test(control_emotion$resentful,t7_emotion$resentful)
t.test(control_emotion$resentful,t8_emotion$resentful)
t.test(control_emotion$resentful,t9_emotion$resentful)

mean(control_emotion$disgust)
t.test(control_emotion$disgust,t1_emotion$disgust)
t.test(control_emotion$disgust,t2_emotion$disgust)
t.test(control_emotion$disgust,t3_emotion$disgust)
t.test(control_emotion$disgust,t4_emotion$disgust)
t.test(control_emotion$disgust,t5_emotion$disgust)
t.test(control_emotion$disgust,t6_emotion$disgust)
t.test(control_emotion$disgust,t7_emotion$disgust)
t.test(control_emotion$disgust,t8_emotion$disgust)
t.test(control_emotion$disgust,t9_emotion$disgust)

mean(control_emotion$hate)
t.test(control_emotion$hate,t2_emotion$hate)
t.test(control_emotion$hate,t3_emotion$hate)
t.test(control_emotion$hate,t4_emotion$hate)
t.test(control_emotion$hate,t5_emotion$hate)
t.test(control_emotion$hate,t6_emotion$hate)
t.test(control_emotion$hate,t7_emotion$hate)
t.test(control_emotion$hate,t8_emotion$hate)
t.test(control_emotion$hate,t9_emotion$hate)

mean(control_emotion$contempt)
t.test(control_emotion$contempt,t2_emotion$contempt)
t.test(control_emotion$contempt,t3_emotion$contempt)
t.test(control_emotion$contempt,t4_emotion$contempt)
t.test(control_emotion$contempt,t5_emotion$contempt)
t.test(control_emotion$contempt,t6_emotion$contempt)
t.test(control_emotion$contempt,t7_emotion$contempt)
t.test(control_emotion$contempt,t8_emotion$contempt)
t.test(control_emotion$contempt,t9_emotion$contempt)

emotion_summary <- overall_emotion %>% filter (group != "Control Scenario") %>%
  group_by(group) %>%
  summarise(n=n(),
            sd_fear = sd(fear, na.rm = TRUE),se_fear = se(fear, na.rm = TRUE), 
            ic_fear = se_fear*qt((1-0.05)/2 + .5, n-1),
            fear = mean(fear),
            sd_anxiety = sd(anxiety, na.rm = TRUE),se_anxiety= se(anxiety, na.rm = TRUE), 
            ic_anxiety = se_anxiety*qt((1-0.05)/2 + .5, n-1),
            anxiety=mean(anxiety), 
            sd_worry = sd(worry, na.rm = TRUE),se_worry = se(worry, na.rm = TRUE), 
            ic_worry = se_worry*qt((1-0.05)/2 + .5, n-1),
            worry=mean(worry), 
            sd_anger = sd(anger, na.rm = TRUE),se_anger = se(anger, na.rm = TRUE), 
            ic_anger = se_anger*qt((1-0.05)/2 + .5, n-1),
            anger=mean(anger), 
            sd_bitter = sd(bitter, na.rm = TRUE),se_bitter = se(bitter, na.rm = TRUE), 
            ic_bitter = se_bitter*qt((1-0.05)/2 + .5, n-1),
            bitter=mean(bitter),
            sd_resentful = sd(resentful, na.rm = TRUE),se_resentful = se(resentful, na.rm = 
                                                                           TRUE), 
            ic_resentful = se_resentful*qt((1-0.05)/2 + .5, n-1),
            resentful=mean(resentful), 
            sd_disgust = sd(disgust, na.rm = TRUE),se_disgust = se(disgust, na.rm = TRUE), 
            ic_disgust = se_disgust*qt((1-0.05)/2 + .5, n-1),
            disgust=mean(disgust), 
            sd_hate = sd(hate, na.rm = TRUE),se_hate = se(hate, na.rm = TRUE), 
            ic_hate = se_hate*qt((1-0.05)/2 + .5, n-1),
            hate=mean(hate), 
            sd_contempt = sd(contempt, na.rm = TRUE),se_contempt= se(contempt, na.rm = TRUE), 
            ic_contempt = se_contempt*qt((1-0.05)/2 + .5, n-1),
            contempt=mean(contempt)) 

fear <- ggplot(emotion_summary, aes(group, fear)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = fear-ic_fear, ymax = fear+ic_fear), width = 0.2) +
  # geom_errorbar(aes(ymin = fear, ymax = fear+sd), width = 0.2) +
  scale_x_discrete(labels=c("WH, SA",
                            "WH, EE*", 
                            "WH, PE**", 
                            "BR, SA", 
                            "BR, EE",
                            "BR, PE",
                            "BL, SA",
                            "BL, EE**",
                            "BL, PE")) +
  scale_y_continuous(limits = c(1,5)) + 
  #geom_hline(yintercept = mean(control_emotion$fear), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

anxiety <- ggplot(emotion_summary, aes(group, anxiety)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = anxiety-ic_anxiety, ymax = anxiety+ic_anxiety), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("WH, SA",
                            "WH, EE**", 
                            "WH, PE**", 
                            "BR, SA", 
                            "BR, EE*",
                            "BR, PE*",
                            "BL, SA",
                            "BL, EE**",
                            "BL, PE")) +
  scale_y_continuous(limits = c(1,5)) + 
  #geom_hline(yintercept = mean(control_emotion$anxiety), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

worry <- ggplot(emotion_summary, aes(group, worry)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = worry-ic_worry, ymax = worry+ic_worry), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("WH, SA",
                            "WH, EE**", 
                            "WH, PE**", 
                            "BR, SA", 
                            "BR, EE*",
                            "BR, PE",
                            "BL, SA",
                            "BL, EE*",
                            "BL, PE")) +
  scale_y_continuous(limits = c(1,5)) + 
  #geom_hline(yintercept = mean(control_emotion$worry), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

anger <- ggplot(emotion_summary, aes(group, anger)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = anger-ic_anger, ymax = anger+ic_anger), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("WH, SA",
                            "WH, EE*", 
                            "WH, PE**", 
                            "BR, SA", 
                            "BR, EE",
                            "BR, PE**",
                            "BL, SA",
                            "BL, EE**",
                            "BL, PE")) +
  scale_y_continuous(limits = c(1,5)) + 
  #geom_hline(yintercept = mean(control_emotion$anger), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

bitter <- ggplot(emotion_summary, aes(group, bitter)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = bitter-ic_bitter, ymax = bitter+ic_bitter), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("WH, SA",
                            "WH, EE**", 
                            "WH, PE*", 
                            "BR, SA", 
                            "BR, EE",
                            "BR, PE",
                            "BL, SA",
                            "BL, EE*",
                            "BL, PE*")) +
  scale_y_continuous(limits = c(1,5)) + 
  #geom_hline(yintercept = mean(control_emotion$bitter), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

resentful <- ggplot(emotion_summary, aes(group, resentful)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = resentful-ic_resentful, ymax = resentful+ic_resentful), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("Scenario #1, Treatment" = "T1 (WH, SA)",
                            "Scenario #2, Treatment" = "T2 (WH, EE)", 
                            "Scenario #3, Treatment" = "T3 (WH, PE)", 
                            "Scenario #4, Treatment" = "T4 (BR, SA)", 
                            "Scenario #5, Treatment" = "T5 (BR, EE)",
                            "Scenario #6, Treatment" = "T6 (BR, PE)",
                            "Scenario #7, Treatment" = "T7 (BL, SA)",
                            "Scenario #8, Treatment" = "T8 (BL, EE)",
                            "Scenario #9, Treatment" = "T9 (BL, PE)")) +
  scale_y_continuous(limits = c(1,5)) +  
  #geom_hline(yintercept = mean(control_emotion$resentful), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

disgust <- ggplot(emotion_summary, aes(group, disgust)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = disgust-ic_disgust, ymax = disgust+ic_disgust), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("Scenario #1, Treatment" = "T1 (WH, SA)",
                            "Scenario #2, Treatment" = "T2 (WH, EE)", 
                            "Scenario #3, Treatment" = "T3 (WH, PE)", 
                            "Scenario #4, Treatment" = "T4 (BR, SA)", 
                            "Scenario #5, Treatment" = "T5 (BR, EE)",
                            "Scenario #6, Treatment" = "T6 (BR, PE)",
                            "Scenario #7, Treatment" = "T7 (BL, SA)",
                            "Scenario #8, Treatment" = "T8 (BL, EE)",
                            "Scenario #9, Treatment" = "T9 (BL, PE)")) +
  scale_y_continuous(limits = c(1,5)) +  
  #geom_hline(yintercept = mean(control_emotion$disgust), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

hate <- ggplot(emotion_summary, aes(group, hate)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = hate-ic_hate, ymax = hate+ic_hate), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("Scenario #1, Treatment" = "T1 (WH, SA)",
                            "Scenario #2, Treatment" = "T2 (WH, EE)", 
                            "Scenario #3, Treatment" = "T3 (WH, PE)", 
                            "Scenario #4, Treatment" = "T4 (BR, SA)", 
                            "Scenario #5, Treatment" = "T5 (BR, EE)",
                            "Scenario #6, Treatment" = "T6 (BR, PE)",
                            "Scenario #7, Treatment" = "T7 (BL, SA)",
                            "Scenario #8, Treatment" = "T8 (BL, EE)",
                            "Scenario #9, Treatment" = "T9 (BL, PE)")) +
  scale_y_continuous(limits = c(1,5)) +  
  #geom_hline(yintercept = mean(control_emotion$hate), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

contempt <- ggplot(emotion_summary, aes(group, contempt)) +
  #geom_col(fill = "lightgray") +
  geom_pointrange(aes(ymin = contempt-ic_contempt, ymax = contempt+ic_contempt), width = 0.2) +
  # geom_errorbar(aes(ymin = racist, ymax = racist+sd), width = 0.2) +
  scale_x_discrete(labels=c("Scenario #1, Treatment" = "T1 (WH, SA)",
                            "Scenario #2, Treatment" = "T2 (WH, EE)", 
                            "Scenario #3, Treatment" = "T3 (WH, PE)", 
                            "Scenario #4, Treatment" = "T4 (BR, SA)", 
                            "Scenario #5, Treatment" = "T5 (BR, EE)",
                            "Scenario #6, Treatment" = "T6 (BR, PE)",
                            "Scenario #7, Treatment" = "T7 (BL, SA)",
                            "Scenario #8, Treatment" = "T8 (BL, EE)",
                            "Scenario #9, Treatment" = "T9 (BL, PE)")) +
  scale_y_continuous(limits = c(1,5)) +  
  #geom_hline(yintercept = mean(control_emotion$contempt), linetype = 2) +
  #coord_cartesian(ylim=c(1,5)) + https://stackoverflow.com/questions/32505298/explain-ggplot2-warning-removed-k-rows-containing-missing-values
  theme_bw() +
  ylab("") +
  xlab("Experimental Conditions") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("")

ggarrange(fear,anxiety,worry,anger,bitter,
        labels = c("Fear","Anxiety","Worry","Anger","Bitter"),
        ncol = 3, nrow = 2)
```

### 6) Regression Analysis:

```{r results='asis', echo=FALSE, eval=TRUE}
model1 <- lm(supt~factor(race),data=race_regress)
model2 <- lm(supt~factor(race)+sex+age+income+ethnicity,data=race_regress)
model3 <- lm(supt~factor(race)+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress)
stargazer(model1,model2,model3,type = "html", style = "qje",
          digits = 2,
          ci = TRUE,
          title = "Public Support for U.S. Counterterrorism Drone Strikes", 
          covariate.labels = c("White", "Brown", "Black", "Sex", "Age", "Income", "Race", 
            "Ideology","Ethnocentrism","Use of Force","Morality","Domestic Approval","International Law","Racial 
            Resentment","Strike are Racist","Military Service"), 
          dep.var.labels   = "Support",
          df = FALSE,
          omit.stat = c("rsq", "ser")) #regression models for Appendix F, SI
model4 <- lm(supt~factor(location),data=race_regress)
model5 <- lm(supt~factor(location)+sex+age+income+ethnicity,data=race_regress)
model6 <- lm(supt~factor(location)+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress)
stargazer(model4,model5,model6,type = "html", style = "qje",
          digits = 2,
          ci = TRUE,
          title = "Public Support for U.S. Counterterrorism Drone Strikes", 
          covariate.labels = c("South Africa", "Estonia", "Peru", "Sex", "Age", "Income", "Race", 
            "Ideology","Ethnocentrism","Use of Force","Morality","Domestic Approval","International Law","Racial 
            Resentment","Strike are Racist","Military Service"), 
          dep.var.labels   = "Support",
          df = FALSE,
          omit.stat = c("rsq", "ser")) #regression models for Appendix G, SI
model7 <- lm(supt~group,data=race_regress)
model8 <- lm(supt~group+sex+age+income+ethnicity,data=race_regress)
model9 <- lm(supt~group+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress)
stargazer(model7,model8,model8,type = "html", style = "qje",
          digits = 2,
          ci = TRUE,
          title = "Public Support for U.S. Counterterrorism Drone Strikes", 
          covariate.labels = c("White, South Africa","White, Estonia","White, Peru","Brown, South Africa","Brown, Estonia",
            "Brown, Peru","Black, South Africa", "Black, Estonia","Black, Peru","Sex", "Age", "Income", "Race", 
            "Ideology","Ethnocentrism","Use of Force","Morality","Domestic Approval","International Law","Racial 
            Resentment","Strike are Racist","Military Service"), 
          dep.var.labels   = "Support",
          df = FALSE,
          omit.stat = c("rsq", "ser")) #regression models for Table 2, main manuscript
race_regress2 <- race_regress 
race_regress2 %<>% mutate(overall = (time)/60) %>% 
  filter(overall < 11.61 & overall > 1)
race_regress3 <- race_regress2 
race_regress3 %<>% filter(terrorist == 2)
model10 <- lm(supt~group,data=race_regress)
model11 <- lm(supt~group+sex+age+income+ethnicity,data=race_regress)
model12 <- lm(supt~group+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress)
model13 <- lm(supt~group+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress2)
model14 <- lm(supt~group+sex+age+income+ethnicity+party_score+ethno_score+force_score+morality_score+congress_score+legality_score+race_score+racist+military,data=race_regress3)
stargazer(model10,model11,model12,model13,model14,type = "html", style = "qje",
          digits = 2,
          ci = TRUE,
          title = "Public Support for U.S. Counterterrorism Drone Strikes", 
          covariate.labels = c("White, South Africa","White, Estonia","White, Peru","Brown, South Africa","Brown, Estonia",
            "Brown, Peru","Black, South Africa", "Black, Estonia","Black, Peru","Sex", "Age", "Income", "Race", 
            "Ideology","Ethnocentrism","Use of Force","Morality","Domestic Approval","International Law","Racial 
            Resentment","Strike are Racist","Military Service"), 
          dep.var.labels   = "Support",
          df = FALSE,
          omit.stat = c("rsq", "ser")) #regression models for Appendix C, SI
model15 <- lm(supt~group*ethno_score,data=race_regress)
model16 <- lm(supt~group*race_score,data=race_regress)
modelsummary(list(model15,model16), stars = T, output = "") #regression models for Appendix E, SI
```

### 7) Open Ended Analysis: 

```{r open ended questions by group, include=FALSE}
t1_questions  <- questions %>% filter(t1_wa == 1) 
t2_questions  <- questions %>% filter(t2_we == 1) 
t3_questions  <- questions %>% filter(t3_wl == 1) 
t4_questions  <- questions %>% filter(t4_bra == 1)
t5_questions  <- questions %>% filter(t5_bre == 1)
t6_questions  <- questions %>% filter(t6_brl == 1)
t7_questions  <- questions %>% filter(t7_bla == 1)
t8_questions  <- questions %>% filter(t8_ble == 1)
t9_questions  <- questions %>% filter(t9_bll == 1)
```

#### a) Treatment One (White, South Africa):

```{r open ended questions for t1, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t1_questions <- data.frame(t1_questions)
t1_questions_obs <- nrow(t1_questions)
t1_civcas <- (nrow(t1_questions %>% filter(score == 1))/t1_questions_obs)*100
t1_intel <- (nrow(t1_questions %>% filter(score == 2))/t1_questions_obs)*100 
t1_threat <- (nrow(t1_questions %>% filter(score == 3))/t1_questions_obs)*100
t1_potus <- (nrow(t1_questions %>% filter(score == 4))/t1_questions_obs)*100
t1_sovereignty <- (nrow(t1_questions %>% filter(score == 5))/t1_questions_obs)*100
t1_norms <- (nrow(t1_questions %>% filter(score == 6))/t1_questions_obs)*100
t1_legality <- (nrow(t1_questions %>% filter(score == 7))/t1_questions_obs)*100
t1_options <- (nrow(t1_questions %>% filter(score == 8))/t1_questions_obs)*100
t1_soldiers <- (nrow(t1_questions %>% filter(score == 9))/t1_questions_obs)*100
t1_drones <- (nrow(t1_questions %>% filter(score == 10))/t1_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t1_civcas,t1_intel,t1_threat,t1_potus,t1_sovereignty,t1_norms,t1_legality,t1_options,t1_soldiers,t1_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for White, South Africa") #graph for Appendix I, SI
```

#### b) Treatment Two (White, Estonia):

```{r open ended questions for t2, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t2_questions <- data.frame(t2_questions)
t2_questions_obs <- nrow(t2_questions)
t2_civcas <- (nrow(t2_questions %>% filter(score == 1))/t2_questions_obs)*100
t2_intel <- (nrow(t2_questions %>% filter(score == 2))/t2_questions_obs)*100 
t2_threat <- (nrow(t2_questions %>% filter(score == 3))/t2_questions_obs)*100
t2_potus <- (nrow(t2_questions %>% filter(score == 4))/t2_questions_obs)*100
t2_sovereignty <- (nrow(t2_questions %>% filter(score == 5))/t2_questions_obs)*100
t2_norms <- (nrow(t2_questions %>% filter(score == 6))/t2_questions_obs)*100
t2_legality <- (nrow(t2_questions %>% filter(score == 7))/t2_questions_obs)*100
t2_options <- (nrow(t2_questions %>% filter(score == 8))/t2_questions_obs)*100
t2_soldiers <- (nrow(t2_questions %>% filter(score == 9))/t2_questions_obs)*100
t2_drones <- (nrow(t2_questions %>% filter(score == 10))/t2_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t2_civcas,t2_intel,t2_threat,t2_potus,t2_sovereignty,t2_norms,t2_legality,t2_options,t2_soldiers,t2_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for White, Estonia") #graph for Appendix I, SI
```

#### c) Treatment Three (White, Peru):

```{r open ended questions for t3, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t3_questions <- data.frame(t3_questions)
t3_questions_obs <- nrow(t3_questions)
t3_civcas <- (nrow(t3_questions %>% filter(score == 1))/t3_questions_obs)*100
t3_intel <- (nrow(t3_questions %>% filter(score == 2))/t3_questions_obs)*100 
t3_threat <- (nrow(t3_questions %>% filter(score == 3))/t3_questions_obs)*100
t3_potus <- (nrow(t3_questions %>% filter(score == 4))/t3_questions_obs)*100
t3_sovereignty <- (nrow(t3_questions %>% filter(score == 5))/t3_questions_obs)*100
t3_norms <- (nrow(t3_questions %>% filter(score == 6))/t3_questions_obs)*100
t3_legality <- (nrow(t3_questions %>% filter(score == 7))/t3_questions_obs)*100
t3_options <- (nrow(t3_questions %>% filter(score == 8))/t3_questions_obs)*100
t3_soldiers <- (nrow(t3_questions %>% filter(score == 9))/t3_questions_obs)*100
t3_drones <- (nrow(t3_questions %>% filter(score == 10))/t3_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t3_civcas,t3_intel,t3_threat,t3_potus,t3_sovereignty,t3_norms,t3_legality,t3_options,t3_soldiers,t3_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for White, Peru") #graph for Appendix I, SI
```

#### d) Treatment Four (Brown, South Africa):

```{r open ended questions for t4, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t4_questions <- data.frame(t4_questions)
t4_questions_obs <- nrow(t4_questions)
t4_civcas <- (nrow(t4_questions %>% filter(score == 1))/t4_questions_obs)*100
t4_intel <- (nrow(t4_questions %>% filter(score == 2))/t4_questions_obs)*100 
t4_threat <- (nrow(t4_questions %>% filter(score == 3))/t4_questions_obs)*100
t4_potus <- (nrow(t4_questions %>% filter(score == 4))/t4_questions_obs)*100
t4_sovereignty <- (nrow(t4_questions %>% filter(score == 5))/t4_questions_obs)*100
t4_norms <- (nrow(t4_questions %>% filter(score == 6))/t4_questions_obs)*100
t4_legality <- (nrow(t4_questions %>% filter(score == 7))/t4_questions_obs)*100
t4_options <- (nrow(t4_questions %>% filter(score == 8))/t4_questions_obs)*100
t4_soldiers <- (nrow(t4_questions %>% filter(score == 9))/t4_questions_obs)*100
t4_drones <- (nrow(t4_questions %>% filter(score == 10))/t4_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t4_civcas,t4_intel,t4_threat,t4_potus,t4_sovereignty,t4_norms,t4_legality,t4_options,t4_soldiers,t4_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Brown, South Africa") #graph for Appendix I, SI
```

#### e) Treatment Five (Brown, Estonia):

```{r open ended questions for t5, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t5_questions <- data.frame(t5_questions)
t5_questions_obs <- nrow(t5_questions)
t5_civcas <- (nrow(t5_questions %>% filter(score == 1))/t5_questions_obs)*100
t5_intel <- (nrow(t5_questions %>% filter(score == 2))/t5_questions_obs)*100 
t5_threat <- (nrow(t5_questions %>% filter(score == 3))/t5_questions_obs)*100
t5_potus <- (nrow(t5_questions %>% filter(score == 4))/t5_questions_obs)*100
t5_sovereignty <- (nrow(t5_questions %>% filter(score == 5))/t5_questions_obs)*100
t5_norms <- (nrow(t5_questions %>% filter(score == 6))/t5_questions_obs)*100
t5_legality <- (nrow(t5_questions %>% filter(score == 7))/t5_questions_obs)*100
t5_options <- (nrow(t5_questions %>% filter(score == 8))/t5_questions_obs)*100
t5_soldiers <- (nrow(t5_questions %>% filter(score == 9))/t5_questions_obs)*100
t5_drones <- (nrow(t5_questions %>% filter(score == 10))/t5_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t5_civcas,t5_intel,t5_threat,t5_potus,t5_sovereignty,t5_norms,t5_legality,t5_options,t5_soldiers,t5_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Brown, Estonia") #graph for Appendix I, SI
```

#### f) Treatment Six (Brown, Peru):

```{r open ended questions for t6, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t6_questions <- data.frame(t6_questions)
t6_questions_obs <- nrow(t6_questions)
t6_civcas <- (nrow(t6_questions %>% filter(score == 1))/t6_questions_obs)*100
t6_intel <- (nrow(t6_questions %>% filter(score == 2))/t6_questions_obs)*100 
t6_threat <- (nrow(t6_questions %>% filter(score == 3))/t6_questions_obs)*100
t6_potus <- (nrow(t6_questions %>% filter(score == 4))/t6_questions_obs)*100
t6_sovereignty <- (nrow(t6_questions %>% filter(score == 5))/t6_questions_obs)*100
t6_norms <- (nrow(t6_questions %>% filter(score == 6))/t6_questions_obs)*100
t6_legality <- (nrow(t6_questions %>% filter(score == 7))/t6_questions_obs)*100
t6_options <- (nrow(t6_questions %>% filter(score == 8))/t6_questions_obs)*100
t6_soldiers <- (nrow(t6_questions %>% filter(score == 9))/t6_questions_obs)*100
t6_drones <- (nrow(t6_questions %>% filter(score == 10))/t6_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t6_civcas,t6_intel,t6_threat,t6_potus,t6_sovereignty,t6_norms,t6_legality,t6_options,t6_soldiers,t6_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Brown, Peru") #graph for Appendix I, SI
```

#### g) Treatment Seven (Black, South Africa):

```{r open ended questions for t7, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t7_questions <- data.frame(t7_questions)
t7_questions_obs <- nrow(t7_questions)
t7_civcas <- (nrow(t7_questions %>% filter(score == 1))/t7_questions_obs)*100
t7_intel <- (nrow(t7_questions %>% filter(score == 2))/t7_questions_obs)*100 
t7_threat <- (nrow(t7_questions %>% filter(score == 3))/t7_questions_obs)*100
t7_potus <- (nrow(t7_questions %>% filter(score == 4))/t7_questions_obs)*100
t7_sovereignty <- (nrow(t7_questions %>% filter(score == 5))/t7_questions_obs)*100
t7_norms <- (nrow(t7_questions %>% filter(score == 6))/t7_questions_obs)*100
t7_legality <- (nrow(t7_questions %>% filter(score == 7))/t7_questions_obs)*100
t7_options <- (nrow(t7_questions %>% filter(score == 8))/t7_questions_obs)*100
t7_soldiers <- (nrow(t7_questions %>% filter(score == 9))/t7_questions_obs)*100
t7_drones <- (nrow(t7_questions %>% filter(score == 10))/t7_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t7_civcas,t7_intel,t7_threat,t7_potus,t7_sovereignty,t7_norms,t7_legality,t7_options,t7_soldiers,t7_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Black, South Africa") #graph for Appendix I, SI
```

#### h) Treatment Eight (Black, Estonia):

```{r open ended questions for t8, iecho=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t8_questions <- data.frame(t8_questions)
t8_questions_obs <- nrow(t8_questions)
t8_civcas <- (nrow(t8_questions %>% filter(score == 1))/t8_questions_obs)*100
t8_intel <- (nrow(t8_questions %>% filter(score == 2))/t8_questions_obs)*100 
t8_threat <- (nrow(t8_questions %>% filter(score == 3))/t8_questions_obs)*100
t8_potus <- (nrow(t8_questions %>% filter(score == 4))/t8_questions_obs)*100
t8_sovereignty <- (nrow(t8_questions %>% filter(score == 5))/t8_questions_obs)*100
t8_norms <- (nrow(t8_questions %>% filter(score == 6))/t8_questions_obs)*100
t8_legality <- (nrow(t8_questions %>% filter(score == 7))/t8_questions_obs)*100
t8_options <- (nrow(t8_questions %>% filter(score == 8))/t8_questions_obs)*100
t8_soldiers <- (nrow(t8_questions %>% filter(score == 9))/t8_questions_obs)*100
t8_drones <- (nrow(t8_questions %>% filter(score == 10))/t8_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t8_civcas,t8_intel,t8_threat,t8_potus,t8_sovereignty,t8_norms,t8_legality,t8_options,t8_soldiers,t8_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Black, Estonia") #graph for Appendix I, SI
```

#### i) Treatment Nine (Black, Peru):

```{r open ended questions for t9, echo=FALSE, eval=TRUE, include=TRUE, message=FALSE}
t9_questions <- data.frame(t9_questions)
t9_questions_obs <- nrow(t9_questions)
t9_civcas <- (nrow(t9_questions %>% filter(score == 1))/t9_questions_obs)*100
t9_intel <- (nrow(t9_questions %>% filter(score == 2))/t9_questions_obs)*100 
t9_threat <- (nrow(t9_questions %>% filter(score == 3))/t9_questions_obs)*100
t9_potus <- (nrow(t9_questions %>% filter(score == 4))/t9_questions_obs)*100
t9_sovereignty <- (nrow(t9_questions %>% filter(score == 5))/t9_questions_obs)*100
t9_norms <- (nrow(t9_questions %>% filter(score == 6))/t9_questions_obs)*100
t9_legality <- (nrow(t9_questions %>% filter(score == 7))/t9_questions_obs)*100
t9_options <- (nrow(t9_questions %>% filter(score == 8))/t9_questions_obs)*100
t9_soldiers <- (nrow(t9_questions %>% filter(score == 9))/t9_questions_obs)*100
t9_drones <- (nrow(t9_questions %>% filter(score == 10))/t9_questions_obs)*100
Reasoning <- c("Civilian Casualties","Intelligence","Perceived Threat","Presidental Authority","Sovereignty","Normative","Legality","Non-Lethal Options","Force Protection","Capability")
Percent <- c(t9_civcas,t9_intel,t9_threat,t9_potus,t9_sovereignty,t9_norms,t9_legality,t9_options,t9_soldiers,t9_drones)
data <- data.frame(Reasoning,Percent)
data$Reasoning <- factor(data$Reasoning, levels = c("Capability","Civilian Casualties","Force Protection","Intelligence","Legality","Non-Lethal Options","Normative","Perceived Threat","Presidental Authority","Sovereignty"))
ggplot(data, aes(x=Reasoning,y=Percent)) +
  geom_bar(stat="identity", fill = c("grey90","grey85","grey80","grey75","grey70","grey65","grey60","grey55","grey50","grey45")) + 
  geom_text(aes(label = round((Percent), 2)), position = position_dodge(width = 1), vjust=-.25, size=3) +
  theme_bw() +
  ylab("Percentage of Respondents") +
  xlab("Considerations") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
  ggtitle("Justifications for Black, Peru") #graph for Appendix I, SI
```
